# -*- coding:utf-8 -*-
"""
这里是操作拍屏
"""
try:
    import maya.cmds as cmds
    import maya.mel as mel
except Exception as test_ERR:
    print('test')


def resizeResolution(width,height):
    """
    将分辨率强制限定到2048
    :param width:
    :param height:
    :return:
    """
    rheight = int(height*2048/width)
    return 2048,rheight


def openAnti():
    """
    开启抗锯齿
    :return:
    """
    cmds.setAttr('hardwareRenderingGlobals.multiSampleEnable',1)

def createMov(file_path,width,height):
    """
    拍屏生成mov
    :param file_path:  mov输出路径
    :param start_frame: int 起始帧
    :param end_frame:  int  结束帧
    :param width:   int 宽度
    :param height:  int 高度
    :return:
    """
    openAnti()
    start_frame = cmds.playbackOptions(q=1, minTime=True)
    end_frame = cmds.playbackOptions(q=1, maxTime=True)
    rw,rh = resizeResolution(width,height)
    cmds.playblast(s="ohNo",fo=True, st=start_frame, et=end_frame, f=file_path, percent=100, fmt='qt',
                   wh=(rw, rh))















